﻿using OA.Models.Enums;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace OA.Models.ViewModels
{
    /// <summary>
    ///  用户账户注册模型
    /// </summary>
    public class RegisterViewModel
    {
        [Required]
        [DisplayName("工号")]
        public string Id { get; set; }
        [Required]
        [DisplayName("密码")]
        [DataType(DataType.Password)]
        [StringLength(160, MinimumLength = 6)]
        public string Password { get; set; }
        [Required]
        [Compare("Password")]
        [DisplayName("确认密码")]
        [DataType(DataType.Password)]
        [StringLength(160, MinimumLength = 6)]
        public string ConfirmPassword { get; set; }
        [Required]
        [DisplayName("图形验证码")]
        public string Captcha { get; set; }

        [Required]
        [DisplayName("姓名")]
        public string Name { get; set; }
        [DefaultValue(0)]
        [DisplayName("性别")]
        public Gender Gender { get; set; }
        [DisplayName("生日")]
        [DataType(DataType.Date)]
        public DateTime? Birthday { get; set; }
        [DisplayName("邮箱地址")]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }
        [DisplayName("手机号码")]
        [DataType(DataType.PhoneNumber)]
        public string Phone { get; set; }
        [Required]
        [DisplayName("岗位")]
        public int PostId { get; set; }
        [Required]
        [DisplayName("部门")]
        public int DepartmentId { get; set; }
    }

    /// <summary>
    ///  用户账号登录模型
    /// </summary>
    public class LoginViewModel
    {
        [Required]
        [DisplayName("工号")]
        public string Id { get; set; }
        [Required]
        [DataType(DataType.Password)]
        [DisplayName("密码")]
        public string Password { get; set; }
        [Required]
        [DisplayName("图形验证码")]
        public string Captcha { get; set; }
    }

    /// <summary>
    ///  用于账号增加和修改的模型
    /// </summary>
    public class AccountViewModel
    {
        /// <summary>
        ///  是否是编辑
        /// </summary>
        public bool IsEdit { get; set; }
        /// <summary>
        ///  是否是管理员
        /// </summary>
        public bool IsAdmin { get; set; }

        [Required]
        [DisplayName("工号")]
        public string Id { get; set; }
        [Required]
        [DisplayName("密码")]
        [DataType(DataType.Password)]
        [StringLength(160, MinimumLength = 5, ErrorMessage = "密码长度要在5到160个字符")]
        public string Password { get; set; }
        [DisplayName("头像")]
        public string Photo { get; set; }
        [Required]
        [DisplayName("姓名")]
        public string Name { get; set; }
        [DefaultValue(0)]
        [DisplayName("性别")]
        public Gender Gender { get; set; }
        [DisplayName("生日")]
        [DataType(DataType.Date)]
        public DateTime? Birthday { get; set; }
        [DisplayName("邮箱地址")]
        [DataType(DataType.EmailAddress)]
        [RegularExpression(@"^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+", ErrorMessage = "邮箱格式不正确")]
        public string Email { get; set; }
        [Phone]
        [DisplayName("手机号码")]
        [DataType(DataType.PhoneNumber)]
        [RegularExpression(@"^1[3458][0-9]{9}$", ErrorMessage = "手机号格式不正确")]
        public string Phone { get; set; }
        [Required]
        [DisplayName("岗位")]
        public int PostId { get; set; }
        [Required]
        [DisplayName("部门")]
        public int DepartmentId { get; set; }
        [DisplayName("在职状态")]
        public EmployeeState State { get; set; }
    }
}
